package com.enki.cigarettes.controller;

import com.enki.cigarettes.controller.vo.response.*;
import com.enki.cigarettes.entity.*;
import com.enki.cigarettes.enums.ProductEnums;
import com.enki.cigarettes.handler.Response;
import com.enki.cigarettes.repository.*;
import com.enki.cigarettes.statics.StaticKeys;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.time.LocalDateTime;
import java.util.*;

/**
 * @author WCS.Wang
 * @version V1.0
 * @Package com.enki.cigarettes.controller
 * @Name e-cigarettes-shop-api-module
 * @Description: TODO 商品信息逻辑层
 * @date 2019-07-19
 */
@RestController
@RequestMapping("/api/products")
@Slf4j
public class ProductController {

    @Autowired
    ProductTRepository productTRepository;
    @Autowired
    ProductPictureTRepository productPictureTRepository;
    @Autowired
    ProductSkuTRepository productSkuTRepository;
    @Autowired
    CategoryAttrValTRepository categoryAttrValTRepository;
    @Autowired
    CategoryAttrTRepository categoryAttrTRepository;
    @Autowired
    ProductCommentTRepository productCommentTRepository;
    @Autowired
    ProductFollowTRepository productFollowTRepository;

    @ApiOperation(value = "分页查询商品信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码", required = true, dataType = "int"),
            @ApiImplicitParam(name = "size", value = "每页数据", required = true, dataType = "int"),
            @ApiImplicitParam(name = "productSort", value = "商品排序类型", dataType = "int", required = true),
            @ApiImplicitParam(name = "sortType", value = "排序方式", dataType = "int", required = true),
            @ApiImplicitParam(name = "source", value = "语言类型", dataType = "int", required = true)
    })
    @GetMapping
    public Object findByPage(@RequestParam(defaultValue = "0") int page,
                             @RequestParam(defaultValue = "10") int size,
                             @RequestParam(defaultValue = "0") int productSort,
                             @RequestParam(defaultValue = "0") int sortType,
                             @RequestParam(defaultValue = "") String keyword,
                             @RequestParam(defaultValue = "0") int source) {
        try {
            Map<String, Object> responseData = new HashMap<>();
            Sort sort = new Sort(Sort.Direction.DESC, StaticKeys.SORT_UPDATE_TIME);
            if (productSort == 0) {

            } else if (productSort == 1) {
                sort = new Sort(Sort.Direction.DESC, "totalSales");
            } else if (productSort == 2) {
                if (sortType == 0) {
                    sort = new Sort(Sort.Direction.ASC, "lowestPrice");
                } else if (sortType == 1) {
                    sort = new Sort(Sort.Direction.DESC, "lowestPrice");
                }
            }
            Pageable pageable = PageRequest.of(page, size, sort);
            List<ProductsResponseVo> beanVoList = new ArrayList<>();
            Specification<ProductT> specification = new Specification<ProductT>() {
                @Override
                public Predicate toPredicate(Root<ProductT> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
                    List<Predicate> predicateList = new ArrayList<>();
                    if (StringUtils.isNotBlank(keyword)) {
                        predicateList.add(criteriaBuilder.like(root.get("name"), "%" + keyword + "%"));
                    }
                    predicateList.add(criteriaBuilder.equal(root.get("status"), ProductEnums.ProductStatus.ONTHSHELF.getType()));
                    predicateList.add(criteriaBuilder.equal(root.get("source"), source));
                    Predicate[] predicates = new Predicate[predicateList.size()];
                    query.where(predicateList.toArray(predicates));
                    query.distinct(true);
                    return query.getRestriction();
                }
            };
            Page<ProductT> beanPage = productTRepository.findAll(specification, pageable);
            for (ProductT productBean : beanPage.getContent()) {
                ProductsResponseVo voBean = new ProductsResponseVo();
                voBean.setId(String.valueOf(productBean.getId()));
                voBean.setName(productBean.getName());
                voBean.setTitle(productBean.getTitle());
                // 最低价格
                List<ProductSkuT> productSkuBeanList = productSkuTRepository.findByProductTIdAndStatus(productBean.getId(), ProductEnums.ProductSkuStatus.ONTHESHELF.getType(), new Sort(Sort.Direction.ASC,"salePrice"));
                if(productSkuBeanList.size() > 0) {
                    voBean.setPrice(Double.valueOf(productSkuBeanList.get(0).getSalePrice()) / 100 + "");
                } else {
                    voBean.setPrice(Double.valueOf(productBean.getLowestPrice()) / 100 + "");
                }
                // 商品主图
                List<ProductPictureT> pictureList = productPictureTRepository.findByProductTIdAndIsMaster(productBean.getId(), true);
                if (pictureList.size() >= 1) {
                    voBean.setPicture(pictureList.get(0).getPhotoPath());
                }
                // 商品评论数量
                Long commentCount = productCommentTRepository.countByProductTId(productBean.getId());
                voBean.setCommentCount(commentCount);
                // 好评率
                Long praiseCount = productCommentTRepository.countByProductTIdAndScoreGreaterThanEqual(productBean.getId(), 5);
                // 好评率
                if (commentCount > 0 && praiseCount > 0) {
                    Double praise = (praiseCount.doubleValue() / commentCount.doubleValue());
                    BigDecimal bg = new BigDecimal(praise).setScale(2, RoundingMode.UP);
                    voBean.setPraise(bg.doubleValue() * 100);
                } else {
                    voBean.setPraise(0.00);
                }
                beanVoList.add(voBean);
            }
            responseData.put("content", beanVoList);
            responseData.put("number", beanPage.getNumber());
            responseData.put("totalPages", beanPage.getTotalPages());
            responseData.put("totalElements", beanPage.getTotalElements());
            responseData.put("size", beanPage.getSize());
            responseData.put("last", beanPage.isLast());
            return Response.success(responseData, StaticKeys.SUCCESS);
        } catch (Exception e) {
            log.error("获取商品列表失败：" + e.getMessage());
            e.printStackTrace();
            return Response.serverError_500("获取商品列表失败");
        }
    }

    @ApiOperation(value = "获取商品详情")
    @ApiImplicitParam(name = "id", value = "商品ID", dataType = "long", required = true)
    @GetMapping(value = "/{id}")
    public Object findById(@PathVariable long id, HttpSession session) {
        try {
            Map<String, Object> responseData = new HashMap<>();
            String productColorSkuName = "颜色";
            String productSizeSkuName = "尺码";
            ProductT productBean = productTRepository.findOneByIdAndStatus(id, ProductEnums.ProductStatus.ONTHSHELF.getType());
            if (productBean == null) {
                return Response.notFound_404("不存在的商品信息");
            }
            Sort sort = new Sort(Sort.Direction.DESC, StaticKeys.SORT_CREATE_TIME);
            // 处理sku的逻辑
            List<ProductSkuT> productSkuBeanList = productSkuTRepository.findByProductTIdAndStatus(productBean.getId(), ProductEnums.ProductSkuStatus.ONTHESHELF.getType(), new Sort(Sort.Direction.ASC,"salePrice"));
            Map<String, ProductSkuT> colorSkuMap = new LinkedHashMap<>();
            Map<String, String> sizeSkuMap = new LinkedHashMap<>();
            for (ProductSkuT productSkuBean : productSkuBeanList) {
                String[] skuArr = productSkuBean.getSkuCode().split(StaticKeys.PRODUCT_SKU_SPLIT);
                // 第一位是颜色
                // 第二位是尺码
                if (skuArr.length == 2) {
                    //颜色
                    CategoryAttrValT categoryAttrValBean = categoryAttrValTRepository.findOneById(skuArr[0]);
                    CategoryAttrT categoryAttrBean = categoryAttrTRepository.findOneById(categoryAttrValBean.getCategoryAttrTId());
                    //尺码
                    CategoryAttrValT sizeSkuAttrVel = categoryAttrValTRepository.findOneById(skuArr[1]);
                    CategoryAttrT sizeSkuAttr = categoryAttrTRepository.findOneById(sizeSkuAttrVel.getCategoryAttrTId());
                    if (categoryAttrBean != null && categoryAttrBean.isIsColor()) {
                        if(colorSkuMap.get(skuArr[0]) == null) {
                            colorSkuMap.put(skuArr[0], productSkuBean);
                        }
                        sizeSkuMap.put(skuArr[1], skuArr[1]);
                        productColorSkuName = categoryAttrBean.getName();
                        productSizeSkuName = sizeSkuAttr.getName();
                    } else {
                        if(colorSkuMap.get(skuArr[1]) == null) {
                            colorSkuMap.put(skuArr[1], productSkuBean);
                        }
                        sizeSkuMap.put(skuArr[0], skuArr[0]);
                        productColorSkuName = categoryAttrBean.getName();
                        productSizeSkuName = sizeSkuAttr.getName();

                    }
                } else if (skuArr.length == 1) {
                    colorSkuMap.put(skuArr[0], productSkuBean);
                    //颜色
                    CategoryAttrValT categoryAttrValBean = categoryAttrValTRepository.findOneById(skuArr[0]);
                    CategoryAttrT categoryAttrBean = categoryAttrTRepository.findOneById(categoryAttrValBean.getCategoryAttrTId());
                    productColorSkuName = categoryAttrBean.getName();

                }
            }
            //获取颜色的sku
            List<ProductColorSkuResponseVo> productColorSkuBeanList = new ArrayList<>();
            List<CategoryAttrValT> productSizeSkuBeanList = new ArrayList<>();
            for (String colorKey : colorSkuMap.keySet()) {
                ProductColorSkuResponseVo colorSkuResponseVo = new ProductColorSkuResponseVo();
                CategoryAttrValT colorSkuAttrVal = categoryAttrValTRepository.findOneById(colorKey);
                ProductSkuT colorValueBean = colorSkuMap.get(colorKey);
                colorSkuResponseVo.setId(colorKey);
                colorSkuResponseVo.setProductId(id);
                colorSkuResponseVo.setName(colorSkuAttrVal.getName());
                colorSkuResponseVo.setSkuPicture(colorValueBean.getSkuPicture());
                colorSkuResponseVo.setMemberPrice(colorValueBean.getMemberPrice() / 100 + "");
                colorSkuResponseVo.setPrice(colorValueBean.getPrice() / 100 + "");
                colorSkuResponseVo.setSalePrice(colorValueBean.getSalePrice() / 100 + "");
                productColorSkuBeanList.add(colorSkuResponseVo);
            }
            //获取尺码的sku
            for (String sizeKey : sizeSkuMap.keySet()) {
                String sizeValue = sizeSkuMap.get(sizeKey);
                if (StringUtils.isNotBlank(sizeValue)) {
                    productSizeSkuBeanList.add(categoryAttrValTRepository.findOneById(sizeValue));
                }
            }
            // 图片信息
            List<ProductPictureT> productPictureBeanList = productPictureTRepository.findByProductTId(productBean.getId(), new Sort(Sort.Direction.ASC, "photoPosition"));
            // 商品相关数据
            ProductDetailResponseVo voBean = new ProductDetailResponseVo();
            voBean.setId(productBean.getId());
            voBean.setName(productBean.getName());
            voBean.setSkuPicture(productSkuBeanList.get(0).getSkuPicture());
            voBean.setPrice(productSkuBeanList.get(0).getSalePrice() / 100 + "");
            voBean.setProductDetail(productBean.getProductDetail());
            voBean.setPictureItems(productPictureBeanList);
            voBean.setProductColorSkuItems(productColorSkuBeanList);
            voBean.setProductColorSkuName(productColorSkuName);
            voBean.setProductSizeSkuItems(productSizeSkuBeanList);
            voBean.setProductSizeSkuName(productSizeSkuName);
            // 商品评论数量
            Long commentCount = productCommentTRepository.countByProductTId(productBean.getId());
            voBean.setCommentCount(commentCount);
            // 好评率
            Long praiseCount = productCommentTRepository.countByProductTIdAndScoreGreaterThanEqual(productBean.getId(), 5);
            // 好评率
            if (commentCount > 0 && praiseCount > 0) {
                Double praise = (praiseCount.doubleValue() / commentCount.doubleValue());
                BigDecimal bg = new BigDecimal(praise).setScale(1, RoundingMode.UP);
                voBean.setPraise(bg.doubleValue() * 100);
            } else {
                voBean.setPraise(0.00);
            }
            Object sessionId = session.getAttribute(StaticKeys.USER_ID);
            if (sessionId != null) {
                ProductFollowT productFollow = productFollowTRepository.findOneByUserTIdAndProductId(sessionId.toString(), id);
                if (productFollow != null) {
                    voBean.setFollowStatus(true);
                }
            }
            return Response.success(voBean, StaticKeys.SUCCESS);
        } catch (Exception e) {
            log.error("获取商品详情失败：" + e.getMessage());
            e.printStackTrace();
            return Response.serverError_500("获取商品详情失败");
        }
    }

    @ApiOperation(value = "根据颜色sku获取尺码信息")
    @GetMapping(value = "/color/{id}/{colorSku}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品ID", dataType = "long", required = true),
            @ApiImplicitParam(name = "colorSku", value = "颜色sku", dataType = "String"),
    })
    public Object findProductSizeSkuByColor(@PathVariable long id, @PathVariable String colorSku, String selectSizeSkuId) {
        try {
            Map<String, Object> responseData = new HashMap<>();
            ProductT productBean = productTRepository.findOneByIdAndStatus(id, ProductEnums.ProductStatus.ONTHSHELF.getType());
            if (productBean != null) {
                Sort sort = new Sort(Sort.Direction.DESC, StaticKeys.SORT_CREATE_TIME);
                List<ProductSizeSkuResponseVo> productSizeSkuBeanList = new ArrayList<>();
                List<ProductSkuT> productSkuBeanList = productSkuTRepository.findByProductTIdAndSkuCodeLikeAndStatus(id, "%" + colorSku + "%", ProductEnums.ProductSkuStatus.ONTHESHELF.getType(), new Sort(Sort.Direction.ASC,"salePrice"));
                for (ProductSkuT productSkuBean : productSkuBeanList) {
                    String[] skuArr = productSkuBean.getSkuCode().split(StaticKeys.PRODUCT_SKU_SPLIT);
                    if (skuArr.length == 2) {
                        CategoryAttrValT categoryAttrValBean = categoryAttrValTRepository.findOneById(skuArr[0]);
                        if (categoryAttrValBean != null) {
                            CategoryAttrT categoryAttrBean = categoryAttrTRepository.findOneById(categoryAttrValBean.getCategoryAttrTId());
                            if (categoryAttrBean != null && categoryAttrBean.isIsColor()) {
                                ProductSizeSkuResponseVo sizeSkuVo = new ProductSizeSkuResponseVo();
                                sizeSkuVo.setId(skuArr[1]);
                                sizeSkuVo.setProductId(productBean.getId());
                                CategoryAttrValT categoryAttrValSizeBean = categoryAttrValTRepository.findOneById(skuArr[1]);
                                if (categoryAttrValSizeBean != null) {
                                    sizeSkuVo.setName(categoryAttrValSizeBean.getName());
                                }
                                if (skuArr[1].equals(selectSizeSkuId)) {
                                    sizeSkuVo.setSelectStatus(true);
                                }
                                productSizeSkuBeanList.add(sizeSkuVo);
                            } else {
                                ProductSizeSkuResponseVo sizeSkuVo = new ProductSizeSkuResponseVo();
                                sizeSkuVo.setId(skuArr[0]);
                                sizeSkuVo.setProductId(productBean.getId());
                                CategoryAttrValT categoryAttrValSizeBean = categoryAttrValTRepository.findOneById(skuArr[0]);
                                if (categoryAttrValSizeBean != null) {
                                    sizeSkuVo.setName(categoryAttrValSizeBean.getName());
                                }
                                productSizeSkuBeanList.add(sizeSkuVo);
                            }
                        }
                    }
                }
                responseData.put("productSkuStatus", true);
                responseData.put("productSkuBeanStatus", false);
                if (StringUtils.isNotBlank(colorSku) && StringUtils.isNotBlank(selectSizeSkuId)) {
                    String skuCode_1 = colorSku + StaticKeys.PRODUCT_SKU_SPLIT + selectSizeSkuId;
                    ProductSkuT productSkuBean = productSkuTRepository.findOneByProductTIdAndSkuCodeAndStatus(id, skuCode_1, ProductEnums.ProductSkuStatus.ONTHESHELF.getType());
                    if (productSkuBean != null) {
                        ProductSkuResponseVo vo = new ProductSkuResponseVo();
                        vo.setSalePrice(Double.valueOf(productSkuBean.getSalePrice()) / 100 + "");
                        vo.setPrice(Double.valueOf(productSkuBean.getPrice()) / 100 + "");
                        responseData.put("productSkuBeanStatus", true);
                        responseData.put("productSkuBean", vo);
                    } else {
                        String skuCode_2 = selectSizeSkuId + StaticKeys.PRODUCT_SKU_SPLIT + colorSku;
                        productSkuBean = productSkuTRepository.findOneByProductTIdAndSkuCodeAndStatus(id, skuCode_2, ProductEnums.ProductSkuStatus.ONTHESHELF.getType());
                        if (productSkuBean != null) {
                            ProductSkuResponseVo vo = new ProductSkuResponseVo();
                            vo.setSalePrice(Double.valueOf(productSkuBean.getSalePrice()) / 100 + "");
                            vo.setPrice(Double.valueOf(productSkuBean.getPrice()) / 100 + "");
                            responseData.put("productSkuBeanStatus", true);
                            responseData.put("productSkuBean", vo);
                        }
                    }
                } else if (StringUtils.isNotBlank(colorSku)) {
                    String skuCode_1 = colorSku;
                    ProductSkuT productSkuBean = productSkuTRepository.findOneByProductTIdAndSkuCodeAndStatus(id, skuCode_1, ProductEnums.ProductSkuStatus.ONTHESHELF.getType());
                    if (productSkuBean != null && productSkuBean.getSkuCode().indexOf(StaticKeys.PRODUCT_SKU_SPLIT) == -1) {
                        ProductSkuResponseVo vo = new ProductSkuResponseVo();
                        vo.setSalePrice(Double.valueOf(productSkuBean.getSalePrice()) / 100 + "");
                        vo.setPrice(Double.valueOf(productSkuBean.getPrice()) / 100 + "");
                        responseData.put("productSkuBeanStatus", true);
                        responseData.put("productSkuBean", vo);
                    }
                }
                responseData.put("productSizeSkuList", productSizeSkuBeanList);
                return Response.success(responseData, StaticKeys.SUCCESS);
            } else {
                return Response.notFound_404("不存在的商品");
            }
        } catch (Exception e) {
            log.error("获取商品详情失败：" + e.getMessage());
            e.printStackTrace();
            return Response.serverError_500("服务器错误，获取商品详情失败");
        }
    }

    @ApiOperation(value = "根据尺码sku获取颜色信息")
    @GetMapping(value = "/size/{id}/{sizeSku}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品ID", dataType = "long", required = true),
            @ApiImplicitParam(name = "sizeSku", value = "尺码sku", dataType = "String"),
    })
    public Object findProductColorSkuBySize(@PathVariable long id, @PathVariable String sizeSku, String selectColorSkuId) {
        try {
            Map<String, Object> responseData = new HashMap<>();
            ProductT productBean = productTRepository.findOneByIdAndStatus(id, ProductEnums.ProductStatus.ONTHSHELF.getType());
            if (productBean != null) {
                Sort sort = new Sort(Sort.Direction.DESC, StaticKeys.SORT_CREATE_TIME);
                List<ProductColorSkuResponseVo> productColorSkuBeanList = new ArrayList<>();
                List<ProductSkuT> productSkuBeanList = productSkuTRepository.findByProductTIdAndSkuCodeLikeAndStatus(id, "%" + sizeSku + "%", ProductEnums.ProductSkuStatus.ONTHESHELF.getType(), new Sort(Sort.Direction.ASC,"salePrice"));
                for (ProductSkuT productSkuBean : productSkuBeanList) {
                    String[] skuArr = productSkuBean.getSkuCode().split(StaticKeys.PRODUCT_SKU_SPLIT);
                    if (skuArr.length == 2) {
                        CategoryAttrValT categoryAttrValBean = categoryAttrValTRepository.findOneById(skuArr[0]);
                        CategoryAttrT categoryAttrBean = categoryAttrTRepository.findOneById(categoryAttrValBean.getCategoryAttrTId());
                        if (categoryAttrBean != null && categoryAttrBean.isIsColor()) {
                            ProductColorSkuResponseVo colorSkuResponseVo = new ProductColorSkuResponseVo();
                            CategoryAttrValT colorSkuAttrVal = categoryAttrValTRepository.findOneById(skuArr[0]);
                            colorSkuResponseVo.setId(skuArr[0]);
                            colorSkuResponseVo.setProductId(id);
                            colorSkuResponseVo.setName(colorSkuAttrVal.getName());
                            colorSkuResponseVo.setSkuPicture(productSkuBean.getSkuPicture());
                            colorSkuResponseVo.setMemberPrice(Double.valueOf(productSkuBean.getMemberPrice()) / 100 + "");
                            colorSkuResponseVo.setPrice(Double.valueOf(productSkuBean.getPrice()) / 100 + "");
                            colorSkuResponseVo.setSalePrice(Double.valueOf(productSkuBean.getSalePrice()) / 100 + "");
                            if (skuArr[0].equals(selectColorSkuId)) {
                                colorSkuResponseVo.setSelectStatus(true);
                            }
                            productColorSkuBeanList.add(colorSkuResponseVo);
                        }
                    } else if (skuArr.length == 1) {
                        ProductColorSkuResponseVo colorSkuResponseVo = new ProductColorSkuResponseVo();
                        CategoryAttrValT colorSkuAttrVal = categoryAttrValTRepository.findOneById(skuArr[0]);
                        colorSkuResponseVo.setId(skuArr[0]);
                        colorSkuResponseVo.setProductId(id);
                        colorSkuResponseVo.setName(colorSkuAttrVal.getName());
                        colorSkuResponseVo.setMemberPrice(Double.valueOf(productSkuBean.getMemberPrice()) / 100 + "");
                        colorSkuResponseVo.setPrice(Double.valueOf(productSkuBean.getPrice()) / 100 + "");
                        colorSkuResponseVo.setSalePrice(Double.valueOf(productSkuBean.getSalePrice()) / 100 + "");
                        if (skuArr[0].equals(selectColorSkuId)) {
                            colorSkuResponseVo.setSelectStatus(true);
                        }
                        productColorSkuBeanList.add(colorSkuResponseVo);
                    }
                }
                responseData.put("productSkuStatus", true);
                responseData.put("productSkuBeanStatus", false);
                if (StringUtils.isNotBlank(selectColorSkuId) && StringUtils.isNotBlank(sizeSku)) {
                    String skuCode_1 = selectColorSkuId + StaticKeys.PRODUCT_SKU_SPLIT + sizeSku;
                    ProductSkuT productSkuBean = productSkuTRepository.findOneByProductTIdAndSkuCodeAndStatus(id, skuCode_1, ProductEnums.ProductSkuStatus.ONTHESHELF.getType());
                    if (productSkuBean != null) {
                        ProductSkuResponseVo vo = new ProductSkuResponseVo();
                        vo.setPrice(Double.valueOf(productSkuBean.getPrice()) / 100 + "");
                        vo.setSalePrice(Double.valueOf(productSkuBean.getSalePrice()) / 100 + "");
                        responseData.put("productSkuBeanStatus", true);
                        responseData.put("productSkuBean", vo);
                    } else {
                        String skuCode_2 = sizeSku + StaticKeys.PRODUCT_SKU_SPLIT + selectColorSkuId;
                        productSkuBean = productSkuTRepository.findOneByProductTIdAndSkuCodeAndStatus(id, skuCode_2, ProductEnums.ProductSkuStatus.ONTHESHELF.getType());
                        if (productSkuBean != null) {
                            ProductSkuResponseVo vo = new ProductSkuResponseVo();
                            vo.setSalePrice(Double.valueOf(productSkuBean.getSalePrice()) / 100 + "");
                            vo.setPrice(Double.valueOf(productSkuBean.getPrice()) / 100 + "");
                            responseData.put("productSkuBeanStatus", true);
                            responseData.put("productSkuBean", vo);
                        }
                    }
                }
                responseData.put("productColorSkuList", productColorSkuBeanList);
                return Response.success(responseData, StaticKeys.SUCCESS);
            } else {
                return Response.notFound_404("不存在的商品");
            }
        } catch (Exception e) {
            log.error("获取商品详情失败：" + e.getMessage());
            e.printStackTrace();
            return Response.serverError_500("服务器错误，获取商品详情失败");
        }
    }

}
